<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/css/font/iconfont.css}" media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/js/layui/css/layui.css}"  media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/bootstrap/bootstrap/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/bootstrap-table/bootstrap-table.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/table.css}"  media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/bootstrap/bootstrap/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/js/select2/css/select2.css}" media="all"/>
    <style>
        .blocks{
            display: flex;
            flex-direction: column;
            width: 20rem;
            height: 6rem;
        }
        .blockout{
            display: flex;
            justify-content: space-between;
            margin: 1.5rem 0;
            padding: 0 1rem;
        }
    </style>
</head>
<body>
<div class="layui-fluid larry-wrapper" id="StandardVUE">
    <div class="layui-row layui-col-space30">
        <div class="layui-col-xs24">
            <section class="panel panel-padding">
                <div style="height: 20rem;" class="layui-collapse" lay-filter="test">
                    <form id="form1" class="layui-form layui-form-pane" action="">
                        <div class="blockout">
                            <div class="blocks">
                                <label>承运商类别</label>
                                <div class="layui-input-inline">
                                    <!--<input type="text" class="layui-input" name="wareHouseName" id="wareHouseName" placeholder="仓库名称"/>-->
                                    <select lay-filter="forwardingAgent"
                                            lay-verify="required"
                                            lay-search
                                            id="forwardingAgent"
                                            name="forwardingAgent"
                                            placeholder="请选择承运商类别">
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" style="margin: 2rem 0;">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </section>
        </div>
    </div>
</div>
</body>
<div th:include="public/public_js::public_js"></div>
<script th:src="@{plugin/beyond/assets/js/fuelux/wizard/wizard-custom.js}"></script>
<script>
    layui.use(['myform','zzpUtils','form','laydate','jquery','zzpValidation'],function () {
        var form = layui.form,
            zzpUtils = layui.zzpUtils
            ,laydate = layui.laydate
            ,zzpValidation = layui.zzpValidation
            ,$ = layui.jquery;

        $(function () {
            $.ajax({
                url: '/zxsswms/wmsshipmentorder/selectCyslb',
                type: 'POST',
                dataType: 'json',
                contentType: 'application/json',
                data: JSON.stringify({}),
                success: function (data) {
                    console.log('data', data);
                    var option = '<option></option>';
                    data.forEach(function (item) {
                        option += '<option value="' + item.d_value + '">'+ item.d_name +'</option>'
                    });
                    $('#forwardingAgent').append(option);
                    form.render('select');
                },
                error: function (err) {

                }
            })
        })

        form.on("submit(add)",function(data) {
            var field = data.field;
            var savedata = {};
            var ids = [];
            ids.push(localStorage['id']);

            if(field.forwardingAgent) {
                savedata.cyslb = field.forwardingAgent;
                savedata.ids = ids;
                $.ajax({
                    url: '/zxsswms/wmsshipmentorder/updateCyslb',
                    type: 'POST',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify(savedata),
                    success: function (data) {
                        if (data.type === 'success') {
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                                top.layer.msg(data.message);
                            },500);
                        }
                    },
                    error: function (err) {

                    }
                })
            }
            return false;
        })

    })
</script>
</html>